<template>
  <div class="assets_componets">
    <div class="assets_amount" v-if="data.remainingSum">
      <div class="amount-item">
        <span class="num">{{data.remainingSum}}</span>
        <span class="text">可用余额</span>
      </div>
      <div class="amount-item">
        <span class="num">{{data.remainingSumFrozen}}</span>
        <span class="text">冻结余额</span>
      </div>
    </div>
    <div class="assets-head">
      <div class="wrapper">
        <button class="btn" :class="{'active': show}" @click="showClick(1)">收益明细</button>
        <button class="btn" :class="{'active': !show}" @click="showClick(0)">支出明细</button>
      </div>
    </div>
    <div v-show="show">
      <v-detail :detail="data.enterRecord" :type="_isType" :regulation="add" :mold="type"></v-detail>
    </div>
    <div v-show="!show">
      <v-detail :detail="data.outRecord" :type="_isType" :regulation="!add" :mold="type"></v-detail>
    </div>
  </div>
</template>

<script>
  import Detail from '@c/detail/detail'

  export default {
    name: 'assets_componets',
    props: {
      data: {
        type: Object,
      },
      type: {
        type: Number,
      },
    },
    data() {
      return {
        show: true,
        balance: ['一星收益', '二星收益', '三星收益', '四星收益', '股东分红', '直推奖', '间推奖', '商家出售所得', '充值', '提现','用户购买','用户积分兑换'],
        integral: ['推荐所得', '购买所得'],
        add: true,
      }
    },
    components: {
      'v-detail': Detail,
    },

    computed: {
      _isType() {
        let arr = []
        if (this.type === 0) {
          arr = this.balance
        } else {
          arr = this.integral
        }

        return arr
      },
    },

    methods: {
      // 点击切换事件
      showClick(val) {
        if (val === 1) {
          this.show = true
          return
        }
        if (val === 0) {
          this.show = false
          return
        }
      },
    },

    mounted() {
    },
    watch: {
      'show'() {
        return this.show
      },
    },
  }
</script>
